package apis

import (
	app "dtf/global_auth/components"
	"fmt"
	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/net/ghttp"
)

const BaseURL = "http://127.0.0.1:10086"

func TestServiceDocument(r *ghttp.Request) {
	var mDoc app.TInstanceDocument
	mDoc.Cmd = "REG"
	mDoc.CmdParams.ServiceName = "Service"
	mR, er := g.Client().Post(BaseURL+"/api_service/commit", g.Map{
		"data": mDoc,
	})
	r.Response.Write("<h1>测试报文提交</h1>")
	r.Response.Write(mR.ReadAllString())
	r.Response.Flush()
	fmt.Println("测试报文提交", er, string(mR.ReadAll()))
}

func TestMQTTComponent(r *ghttp.Request) {
	var mQ app.TMQTTComponent
	mQ.Host = "127.0.0.1"
	mQ.Port = 1883
	_ = mQ.Init()
	_ = mQ.Publish("testtopic", "test")
	mQ.Close()
}
